home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / H-I / HyperTalkHelp.cpt / HyperTalk Tutorial Sampler 1.1 / card_4139.txt < prev    next >
Text File  |  1989-02-26  |  3KB  |  80 lines

  1. -- card: 4139 from stack: in.1
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2619
  5. -- name: 
  6.  
  7.  
  8. -- part 2 (button)
  9. -- low flags: 00
  10. -- high flags: 0000
  11. -- rect: left=44 top=27 right=63 bottom=78
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 32462 / 32462
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: New Button
  20. ----- HyperTalk script -----
  21. on mouseUp
  22.   play "Boing" tempo 120 a
  23.   push card
  24.   visual zoom open
  25.   go to card id 86227 of stack "Help"
  26. end mouseUp
  27.  
  28.  
  29.  
  30. -- part contents for background part 10
  31. ----- text -----
  32. The PUT command is used to copy the contents of one container into another container.  A container can be a field, the message box, or a temporary area you create.  Basically, the Put command allows you to move information around.
  33.  
  34. Click and hold the Test Button down.  Notice the Result field.
  35.  
  36. You can "put" something "into" something, "before" something, or "after" something.
  37.  
  38. into       --to replace
  39. before   --to insert before
  40. after      --to append after
  41.  
  42. To see how these work,  type these two lines after the first "put" command in the Script Window:
  43.              wait 1 seconds
  44.              put "  There!" after field "Result"
  45. Send To Button and Test.  Then change the word "after" to "before".  Send To Button and Test.
  46.  
  47. The "put" command can also be used to create a temporary holding place for information to be used in the handler.  These are also called "temporary variables."If you told HyperCard to 'put "Mark" into myName', it would create a temporary variable called "myName" and put "Mark" into it.  How does it know to create a temporary variable?  It knows because it can't figure out what "myName" is.  Creating temporary variables only works with the "put" command, but once they are created, they can be used like any other container.
  48.  
  49. Let's create a temporary variable for our greeting.  First, click Reset Card to start off fresh.  Then replace the first "put" command with these 2 lines:
  50.           put "Hello" into temporary
  51.           put temporary into field "Result"
  52. Now test the button.  Temporary variables come in handy when you start getting writing more complex scripts.
  53.  
  54. Click ? to find out more about "Put" and "variables".
  55.  
  56. -- part contents for background part 9
  57. ----- text -----
  58. on mouseDown
  59.   put "Hello" into field "Result"
  60. end mouseDown
  61.  
  62. on mouseUp
  63.   put " " into field "Result"
  64. end mouseUp
  65.  
  66.  
  67. -- part contents for background part 13
  68. ----- text -----
  69. on mouseDown
  70.   put "Hello" into field "Result"
  71. end mouseDown
  72.  
  73. on mouseUp
  74.   put " " into field "Result"
  75. end mouseUp
  76.  
  77.  
  78. -- part contents for background part 6
  79. ----- text -----
  80. Put